package cn.iocoder.yudao.module.ems.dal.mysql.outbound;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ems.dal.dataobject.outbound.OutboundDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ems.controller.admin.outbound.vo.*;

/**
 * 出库记录 Mapper
 *
 * @author dason
 */
@Mapper
public interface OutboundMapper extends BaseMapperX<OutboundDO> {

    default PageResult<OutboundDO> selectPage(OutboundPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OutboundDO>()
                .eqIfPresent(OutboundDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(OutboundDO::getTime, reqVO.getBeginTime(), reqVO.getEndTime())
                .eqIfPresent(OutboundDO::getType, reqVO.getType())
                .eqIfPresent(OutboundDO::getOutboundPerson, reqVO.getOutboundPerson())
                .eqIfPresent(OutboundDO::getPickingNo, reqVO.getPickingNo())
                .eqIfPresent(OutboundDO::getPickingDept, reqVO.getPickingDept())
                .eqIfPresent(OutboundDO::getReceiver, reqVO.getReceiver())
                .orderByDesc(OutboundDO::getId));
    }

    default List<OutboundDO> selectList(OutboundExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OutboundDO>()
                .eqIfPresent(OutboundDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(OutboundDO::getTime, reqVO.getBeginTime(), reqVO.getEndTime())
                .eqIfPresent(OutboundDO::getType, reqVO.getType())
                .eqIfPresent(OutboundDO::getOutboundPerson, reqVO.getOutboundPerson())
                .eqIfPresent(OutboundDO::getPickingNo, reqVO.getPickingNo())
                .eqIfPresent(OutboundDO::getPickingDept, reqVO.getPickingDept())
                .eqIfPresent(OutboundDO::getReceiver, reqVO.getReceiver())
                .orderByDesc(OutboundDO::getId));
    }

}
